package org.vectrics.recruiter.job;

import java.util.Comparator;

import org.apache.log4j.Logger;
import org.vectrics.user.PersonNameComparator;


public class JobCandidateNameComparator implements Comparator {
	private transient static Logger log = Logger.getLogger(JobCandidateNameComparator.class);
	private PersonNameComparator userComparator = new PersonNameComparator();
	public JobCandidateNameComparator() {
		super();
		
	}

	
	public int compare(Object o1, Object o2) {
		log.debug("compare() called");
		int result = 0;
		//log.info("compare() - o1 =  " + o1.toString() + "  o2 = " + o2.toString());
		try {
			JobCandidate candidate1 = (JobCandidate)o1;
			JobCandidate candidate2 = (JobCandidate)o2;

			log.debug("compare() - comparing user");
			result = userComparator.compare(candidate1.getCandidate(), candidate2.getCandidate());
		}
		catch (Exception ex) {
			log.error("Exception comparing users", ex);
		}
		log.debug("compare() finished");
		
		return result;
	}

}
